using System;
using DevExpress.XtraGrid.Views.Grid;

namespace CSW.Framework.UI.DevEx.UserControls
{
    /// <summary>
    /// RowDoubleClickEventArgs.
    /// </summary>
    public class RowDoubleClickEventArgs : EventArgs
    {
        private readonly GridView m_View;
        private readonly int m_RowHandle;
        private readonly object m_Item;

        /// <summary>
        /// Initializes a new instance of the <see cref="RowDoubleClickEventArgs"/> class.
        /// </summary>
        /// <param name="view">The grid view.</param>
        /// <param name="rowHandle">The row handle.</param>
        public RowDoubleClickEventArgs(GridView view, int rowHandle)
        {
            m_View = view;
            m_RowHandle = rowHandle;

            if (m_View.IsDataRow(rowHandle))
            {
                m_Item = m_View.GetRow(m_RowHandle);
            }
            else
            {
                m_Item = null;
            }
        }

        /// <summary>
        /// Gets the view.
        /// </summary>
        /// <value>The view.</value>
        public GridView View
        {
            get { return m_View; }
        }

        /// <summary>
        /// Gets the row handle.
        /// </summary>
        /// <value>The row handle.</value>
        public int RowHandle
        {
            get { return m_RowHandle; }
        }

        /// <summary>
        /// Gets the selected item.
        /// </summary>
        public object Item
        {
            get { return m_Item; }
        }
    }
}